
import { Controller, Get, Post, Put, Body, Query, Param, Delete } from '@nestjs/common';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { RequirePermission } from 'src/common/decorators/require-premission.decorator';
import { RecordService } from './record.service';
import { CreateRecordDto, BaseRecordDto, UpdateRecordDto, QueryRecordDto, ListRecordDto } from './dto/record.dto';
import { ApiDataResponse } from 'src/common/decorators/apiDataResponse.decorator';

@ApiTags('退款记录表')
@Controller('system/record')
export class RecordController {
  constructor(private readonly recordService: RecordService) {}

  @ApiOperation({ summary: '退款记录表-创建' })
  @ApiDataResponse(BaseRecordDto)
  @RequirePermission('system:record:add')
  @Post()
  create(@Body() body: CreateRecordDto) {
    return this.recordService.create(body);
  }

  @ApiOperation({ summary: '退款记录表-列表' })
  @ApiDataResponse(ListRecordDto, true, true)
  @RequirePermission('system:record:list')
  @Get('list')
  findAll(@Query() query: QueryRecordDto) {
    return this.recordService.findAll(query);
  }

  @ApiOperation({ summary: '退款记录表-详情' })
  @ApiDataResponse(BaseRecordDto)
  @RequirePermission('system:record:query')
  @Get(':id')
  findOne(@Param('id') id: number) {
    return this.recordService.findOne(id);
  }

  @ApiOperation({ summary: '退款记录表-修改' })
  @ApiDataResponse()
  @RequirePermission('system:record:edit')
  @Put()
  update(@Body() body: UpdateRecordDto) {
    return this.recordService.update(body);
  }

  @ApiOperation({ summary: '退款记录表-删除' })
  @ApiDataResponse()
  @RequirePermission('system:record:remove')
  @Delete(':id')
  remove(@Param('id') id: string) {
    const ids = id.split(',').map((id) => +id);
    return this.recordService.remove(ids);
  }
}